//
//  HDPersonalViewController.m
//  HDecoration
//
//  Created by 曹群 on 15/8/14.
//  Copyright (c) 2015年 HDecoration. All rights reserved.
//

#import "HDPersonalViewController.h"
#import "HDSystemHelpViewController.h"
#import "HDPersonalTableViewController.h"

@interface HDPersonalViewController ()
@property(nonatomic,strong)GXButton *helpBtn;
@property(nonatomic,strong)HDPersonalTableViewController *personalTableView;
@end

@implementation HDPersonalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kContentViewColor;
    [self.view addSubview:self.personalTableView.tableView];
}

- (void)initNavigationBar
{
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                       initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                       target:nil action:nil];
    negativeSpacer.width = -20;
    self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, [[UIBarButtonItem alloc] initWithCustomView:self.helpBtn], nil];
}

- (void)rightBtnAction:(UIButton *)sender
{
    HDSystemHelpViewController *systemHelpVC = [[HDSystemHelpViewController alloc] init];
    systemHelpVC.navigationItem.title = @"系统帮助";
    [self.navigationController pushViewController:systemHelpVC animated:YES];
}




- (void)testDataFunc
{
    //请求个人信息
    NSDictionary* params01=@{
                                @"id":netEngine.coachInfo.m_id,
                           };
    [netEngine RequestCoachInfoWithTarget:self.VctrID hudView:self.personalTableView.tableView Data:params01];    
}

-(void)updateViewController:(NSNotification *)note
{
    NSDictionary* dic=note.userInfo;
    if ([dic objectForKey:Receiver]==self.VctrID)
    {
        if (dic[@"CoachInfo"]!=nil)
        {
            self.personalTableView.personalInfo = dic[@"personalInfo"];
            [self.personalTableView.tableView reloadData];
        }
    }
}

#pragma mark - getters
- (GXButton *)helpBtn
{
    if (!_helpBtn) {
        _helpBtn = [GXButton buttonWithType:UIButtonTypeCustom];
        _helpBtn.frame = CGRectMake(0, 0, 60, 40);
        _helpBtn.imageViewFrame = CGRectMake(15, 15, 25, 9);
        _helpBtn.relayout = YES;
        [_helpBtn setImage:[UIImage imageNamed:@"帮助"] forState:UIControlStateNormal];
        _helpBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
        [_helpBtn addTarget:self action:@selector(rightBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _helpBtn;
}

- (HDPersonalTableViewController *)personalTableView
{
    if (!_personalTableView) {
        _personalTableView = [[HDPersonalTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
        _personalTableView.tableView.frame = CGRectMake(0, 64, APPFRAME.size.width, APPFRAME.size.height-44);
        _personalTableView.tableView.bounces = NO;
    }
    return _personalTableView;
}

@end
